package SortAlgorithm;

import java.util.Arrays;

public class SelectSort {
    public static void main(String[] args) {
        int[] array=new int[]{7,6,5,4,3,2,1};
        System.out.println(Arrays.toString(array));
        selectSort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void selectSort(int[] array){
        for(int i=0;i<array.length;i++){
            int min=i;
            for(int j=i+1;j<array.length;j++){
                if(array[j]<array[min]){
                    min=j;
                }
            }
            swap(array,i,min);
        }
    }
    public static void swap(int[] array,int i,int j){
        int tmp=array[i];
        array[i]=array[j];
        array[j]=tmp;
    }
}
